﻿using Atletika.Shared.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Atletika
{
    public class ArticleTemplateSelector : DataTemplateSelector
    {
        public DataTemplate TopArticleTemplate { get; set; }
        public DataTemplate StandardArticleTemplate { get; set; }

        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            var dataItem = item as Article;
            var uiElement = container as UIElement;

            if (dataItem != null && dataItem.Top)
            {
                VariableSizedWrapGrid.SetColumnSpan(uiElement, 2);
                VariableSizedWrapGrid.SetRowSpan(uiElement, 2);
                return TopArticleTemplate;
            }

            return StandardArticleTemplate;
        }
    }
}
